<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()+ path + "/";
%>
<html>
	 <head>
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
        <meta name="format-detection" content="telephone=no">
        <meta charset="UTF-8">
        <meta name="description" content="Violate Responsive Admin Template">
        <meta name="keywords" content="Super Admin, Admin, Template, Bootstrap">
        <link href="<%=path %>/assets2/js/bootstrap-table.css" rel="stylesheet">
        <script src="<%=path %>/assets2/js/jquery-1.11.1.min.js"></script>
        <script src="<%=path %>/assets2/js/bootstrap-table.js"></script>
   		<script src="<%=path %>/assets2/js/locale/bootstrap-table-zh-CN.js"></script>
   		<script src="<%=path%>/assets2/js/moment-with-locales.min.js"></script>
   		<script src="<%=path%>/assets2/js/bootstrap-datetimepicker.min.js"></script>
		<link rel="stylesheet" href="<%=path%>/assets2/js/bootstrap-datetimepicker.min.css">
		<script src="<%=path %>/assets2/js/validation/validate.min.js"></script>
        <script src="<%=path %>/assets2/js/validation/validationEngine.min.js"></script>
        <script src="<%=path %>/assets2/js/validation/messages_zh.min.js"></script>
        <script src="<%=path %>/assets2/js/jquery.form.js"></script>
        <script src="<%=path %>/assets2/js/bootstrap.min.js"></script>
        <script src="<%=path %>/assets2/js/jquery.timers-1.1.2.js"></script>
    </head>
	<body>
		<div class="row" id="tx" style="display: none;">
			<div class="col-sm-12">
				<span onclick="tixian()" style="font-size: 60px;">提现</span>
			</div>
		</div>
		<div class="row" id="ewmId" style="display: none;">
			<div class="col-sm-12" >
				<img id="ewm">
			</div>
		</div>
		<div class="row" id="showTx" >
			<div class="col-sm-12" id="buttonShow">
				<button onclick="txButton()">提现</button>
			</div>
		</div>
	</body>
   <script>
	$(function(){
		 $('body').everyTime('1s',queryOrder); 
	});
 	//付款
	function tixian(){
	var orderId = 1;
		$.ajax({
	    	url: "<%=path %>/web/createWxQRPay",
	        timeout: 300000,
	        dataType: "json",
	        type: "get",
	        success : function(data) {
	        	console.log(data)
// 	        	var ewmurl ="http://qr.topscan.com/api.php?&bg=ffffff&fg=cc0000&text="+data;
	        	var ewmurl ="https://api.qrserver.com/v1/create-qr-code/?size=150x150&data="+data;
	        	$("#ewm").attr("src",ewmurl)
	        },error : function() {
	        }
	    })
	};
	
	function queryOrder(){
		$.ajax({
	    	url: "<%=path %>/web/queryWebWXPayState",
	        timeout: 300000,
	        dataType: "json",
	        type: "get",
	        success : function(data) {
	        	console.log(data.mapWXResult)
	        	if(data.mapWXResult.trade_state=='SUCCESS'){
	        		$('body').stopTime(); 
	        		$("#ewmId").hide();
	        		$("#tx").hide();
	        		$("#tx").show();
	        		alert("购买服务成功！")
	        	}else if(data.mapWXResult.trade_state=='NOTPAY'){
	        	}else if(data.mapWXResult.trade_state=='CLOSED'){
	        	}else if(data.mapWXResult.trade_state=='REVOKED'){
	        	}else if(data.mapWXResult.trade_state=='PAYERROR'){
	        	}
	        },error : function() {
	        }
	    })
	};
	function txButton(){
		$.ajax({
	    	url: "<%=path %>/web/wxTx",
	        timeout: 300000,
	        dataType: "json",
	        type: "post",
	        success : function(data) {
	        	console.log(data.msg)
	        	if(data.msg==1){
	        		alert("提现成功！")
	        	}else {
	        		alert("提现失败！")
	        	}
	        },error : function() {
	        }
	    })
	}
   </script>
</html>